package com.zzy.jkb.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzy.jkb.api.CommonResult;
import com.zzy.jkb.entity.User;
import com.zzy.jkb.service.IUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.time.LocalDateTime;

/**
 * <p>
 * 用户信息 前端控制器
 * </p>
 *
 * @author zzy
 * @since 2023-02-03
 */
@Controller
@RequestMapping("/jkb/user")
public class UserController {


    @Autowired
    IUserService iUserService;


    @RequestMapping(path = "/save", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("添加用户")
    public CommonResult save(@RequestBody User user) {
        user.setCreateBy("xiangGe");
        user.setCreateTime(LocalDateTime.now());
        user.setVaccinumStatus("未完成基础疫苗");
        return CommonResult.autoCheck(iUserService.save(user));
    }


    @RequestMapping(path = "/getDetail",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("健康码自查旬")
    public CommonResult<User> getDetail(@RequestParam String userId) {


        User user = iUserService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getUuid, userId), false);

        return CommonResult.success(user);
    }

    @RequestMapping(path = "/save1", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("添加用户")
    public void save1() {
        System.out.println("注册成功");

    }


}
